package com.bw.kotlinim

import androidx.fragment.app.Fragment
import com.bw.kotlinim.ui.fragment.ContactFragment
import com.bw.kotlinim.ui.fragment.ConversationFragment
import com.bw.kotlinim.ui.fragment.DynamicFragment

class FragmentFactory private constructor(){//私有化构造函数，单例模式的核心

    private val conversation by lazy { ConversationFragment() }

    private val contact by lazy { ContactFragment() }

    private val dvnamic by lazy { DynamicFragment() }

    companion object{
        val instance = FragmentFactory()
    }

    fun setFragment(tabId:Int):Fragment?{
        when(tabId){
            R.id.tab_conversation->return conversation
            R.id.tab_contacts->return contact
            R.id.tab_dynamic->return dvnamic
        }
         return null
    }

}